﻿using CatLib.Container;
using GameFramework;
using GameFramework.Business;
using GameFramework.Core;
using GameFramework.Update;
using GameLogic.ShootGame.Model;
using GameLogic.ShootGame.System;
using UnityEngine;
using NotImplementedException = System.NotImplementedException;

namespace GameLogic.ShootGame.Controller
{
    /// <summary>
    /// 射击游戏输入控制器
    /// </summary>
    public sealed class ShootGameInputController : AViewController, IUpdate
    {
        [Inject]
        public IShootGameFireSystem FireSystem { get; set; }
        
        [Inject]
        public ShootGameStateModel StateModel { get; set; }

        protected override void OnInitialize()
        {
            Subscribe(StateModel.RemainBulletCount, OnRemainBulletChanged);
        }

        protected override void OnDispose()
        {
        }
        
        public void OnUpdate(float elapseSeconds, float realElapseSeconds)
        {
            if (Input.GetButtonDown("Jump"))
                FireSystem.Fire();
        }

        private void OnRemainBulletChanged(uint oldValue, uint newValue)
        {
            Log.Info($"RemainBulletCount: {newValue}");
        }
    }
}